﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Moon.aspx.cs" Inherits="Catering.Catering_Page.system.Moon" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../Style/center.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/zhezhao.js" type="text/javascript"></script>
    <link href="../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <link href="../../Style/sysData.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        //显示添加
        function Add() {
            $("#txt_Back").val("");
            $("#txt_classId").val("");
            $("#txt_moonName").val("");
            $("#btnEdit").hide();
            $("#btnAdd").show();
            divshow("main", "bg");
        }

        //显示修改
        function Edit(cid) {
            $("#HidID").val(cid);

            $.ajax({
                type: "Post",
                url: "Moon.aspx/Get",
                data: "{'_id':'" + cid + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    $("#txt_id").val(data.d[1] == null ? "" : data.d[1]);
                    $("#txt_moonName").val(data.d[2] == null ? "" : data.d[2]);
                    $("#txt_Back").val(data.d[3] == null ? "" : data.d[3]);

                    $("#btnEdit").show();
                    $("#btnAdd").hide();
                    divshow("main", "bg");
                }
            });
        }

        //添加数据
        function btn_Add() {
            var txt_Back = $("#txt_Back").val();
            //var txt_classId = $("#txt_classId").val();
            var txt_moonName = $("#txt_moonName").val();
            
            $.ajax({
                type: "Post",
                url: "Moon.aspx/Add",
                data: "{'moonName':'" + txt_moonName /*+ "','classId':'" + txt_classId*/ + "','Back':'" + txt_Back + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }

        //修改数据
        function btn_Edit() {
            var txt_Back = $("#txt_Back").val();
            var txt_classId = $("#txt_classId").val();
            var txt_moonName = $("#txt_moonName").val();
            var cid = $("#HidID").val();

            $.ajax({
                type: "Post",
                url: "Moon.aspx/Edit",
                data: "{'_id':'" + cid + "','moonName':'" + txt_moonName + "','classId':'" + txt_classId + "','Back':'" + txt_Back + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    if (data.d == "OK") {
                        alert("保存成功！");
                        window.location.href = window.location.href;
                    }
                }
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:HiddenField ID="HidID" runat="server" />
        <div style="height: 36px; line-height: 36px; font-size: 13px;">&nbsp;当前位置：班组—卫星平台</div>
        <div class="btn_list" style="margin-top: 0px;">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="right" height="30">
                        <input type="button" class="input_btn_a" value="添加" onclick="Add()" />
                    </td>
                    <td width="10"></td>
                </tr>
            </table>
        </div>
        <div class="data_css">
            <table width="100%" border="1" cellpadding="0" cellspacing="0">
                <thead>
                    <tr>
                        <th>序号
                        </th>
                        <th>卫星平台名称
                        </th>
                        <th>班组
                        </th>
                        <th>备注
                        </th>
                        <th>编辑
                        </th>
                        <th>删除
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <asp:Repeater ID="Rep_Moon" runat="server" OnItemCommand="Rep_Moon_ItemCommand">
                        <ItemTemplate>
                            <tr>
                                <td>
                                    <%#Eval("tempId")%>                                    
                                </td>
                                <td>
                                    <%#Eval("MoonName")%>
                                </td>
                                <td>
                                    <%#Eval("ClassName")%>
                                </td>
                                <td>
                                    <%#Eval("Remark")%>
                                </td>
                                <td>
                                    <img alt="" src="../../Images/file.gif" onclick="Edit('<%#Eval("id")%>')" style="cursor: pointer;" />
                                </td>
                                <td>
                                    <asp:ImageButton ID="img_btn" runat="server" ImageUrl="../../Images/trash.gif" OnClientClick="return confirm('确认删除？');"
                                        CommandArgument='<%#Eval("id")%>' CommandName="del" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
        </div>
        <!--弹出层-->
        <div id="bg" class="bg">
        </div>
        <div id="main" class="center_div" style="width: 400px; height: 200px; left:50%;top:30%;margin:-150px 0px 0px -200px">
            <div class="div_0207" style="width: 398px; height: 100%; margin: 0px;">
                <h1>
                    <img src="../../Images/cp_h1_03.gif" />添加卫星平台</h1>
                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="65" height="40" align="right">卫星平台：
                        </td>
                        <td width="110">
                            <asp:HiddenField ID="txt_id" runat="server" />
                            <asp:TextBox ID="txt_moonName" runat="server" CssClass="input_bg" Width="105"></asp:TextBox>
                        </td>
                        <td width="65" align="right">班组名称：
                        </td>
                        <td width="110">                            
                            <asp:Label ID="txt_CName" runat="server" Text=""></asp:Label>
                            <asp:HiddenField ID="txt_classId" runat="server" Value="" />                            
                        </td>
                    </tr>

                    <tr>
                        <td align="right">备　注：
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="txt_Back" runat="server" TextMode="MultiLine" CssClass="input_bg"
                                Style="width: 304px; height: 40px;"></asp:TextBox>
                        </td>
                    </tr>
                </table>
                <table width="100%">
                    <tr>
                        <td height="30" align="right">
                            <input type="button" id="btnAdd" onclick="btn_Add()" class="input_btn_a" value="提交" />
                            <input type="button" id="btnEdit" onclick="btn_Edit()" class="input_btn_a" value="提交" />
                        </td>
                        <td>
                            <input type="button" id="but_Close" onclick='divhidel("main", "bg")' class="input_btn_a"
                                value="关闭" />
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>
</body>
</html>
